'use strict';

if (zxcv && !zxcv.PixelEffect) {
    zxcv.PixelEffect = function () {
    };

    zxcv.ColorMatrixEffect = function () {
        zxcv.PixelEffect.call(this);
        this.red   = [1, 0, 0, 0];
        this.green = [0, 1, 0, 0];
        this.blue  = [0, 0, 1, 0];
        this.alpha = [0, 0, 0, 1];
    };
    zxcv.ColorMatrixEffect.prototype.Effector = function (effect, parent) {
        this.red   = [effect.red[0],   effect.red[1],   effect.red[2],   effect.red[3]];
        this.green = [effect.green[0], effect.green[1], effect.green[2], effect.green[3]];
        this.blue  = [effect.blue[0],  effect.blue[1],  effect.blue[2],  effect.blue[3]];
        this.alpha = [effect.alpha[0], effect.alpha[1], effect.alpha[2], effect.alpha[3]];

        if (parent) {
            this.red[0]   *= effect.red[0];
            this.red[1]   *= effect.red[1];
            this.red[2]   *= effect.red[2];
            this.red[3]   *= effect.red[3];
            this.green[0] *= effect.green[0];
            this.green[1] *= effect.green[1];
            this.green[2] *= effect.green[2];
            this.green[3] *= effect.green[3];
            this.blue[0]  *= effect.blue[0];
            this.blue[1]  *= effect.blue[1];
            this.blue[2]  *= effect.blue[2];
            this.blue[3]  *= effect.blue[3];
            this.alpha[0] *= effect.alpha[0];
            this.alpha[1] *= effect.alpha[1];
            this.alpha[2] *= effect.alpha[2];
            this.alpha[3] *= effect.alpha[3];
        }
    };
    zxcv.ColorMatrixEffect.prototype.Effector.prototype.apply = function (g) {
        g.setValue('RedChannel',   this.red);
        g.setValue('GreenChannel', this.green);
        g.setValue('BlueChannel',  this.blue);
        g.setValue('AlphaChannel', this.alpha);
    };

    zxcv.OpacityMaskFanEffect = function () {
        zxcv.PixelEffect.call(this);
    };

    zxcv.OpacityMaskBarEffect = function () {
        zxcv.PixelEffect.call(this);
    };
}